package GameMain.View.RoomList
{
	import Engine.UIControl.Button;
	
	import GameMain.Game;
	import GameMain.Macro.MacroEvent;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import library.Function.GlobalFun;
	import library.SocketData.SocketData;
	
	public class RoomListItem extends Button
	{
		private var _roomID:int = -1; 
		
		
		public function RoomListItem(p_content:Sprite)
		{
			super(p_content);
			this._content.mouseChildren = false;
			GlobalFun.setTextFormat(this._content["R_ID"],"SimSun",16,true,0xE7B54B);
			GlobalFun.setTextFormat(this._content["R_NUM"],"SimSun",16,true,0xE7B54B);
			
			this._content["R_ID"].filters = [GlobalFun.getBitmapFilter()];
			this._content["R_NUM"].filters = [GlobalFun.getBitmapFilter()];
			
			this.setOnClickFun(this.onJoinRoom);
		}
		
		public function setRoomItemInfo(rID:int,rCNum:int,rTNum:int,rName:String):void
		{
			this._content["R_ID"].text = "房间ID: "+rID;
			this._content["R_NAME"].text = rName;
			this._content["R_NUM"].text = "人数:" + String(rCNum)+"/"+String(rTNum)+"(-)";
			this._roomID = rID;
			if(rCNum == rTNum)
				this.setDisable();
			else
				this.setAble();
		}
		
		private function onJoinRoom():void
		{
			var data:SocketData = new SocketData();
			data.writeInt16(this._roomID);
			Game.EngineMgr.sendMessageData(MacroEvent.MSG_TO_SERVER_JOIN_ROOM,data);
		}
		
	}
}